import { Component, OnInit } from '@angular/core';
import { DataService } from '../../service/data.service';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-course',
  templateUrl: './course.component.html',
  styleUrls: ['./course.component.css']
})
export class CourseComponent implements OnInit {
  id = 1
  dish:any
  dishImgSrc = ''
  windowHeight:number = window.innerHeight
  contentHeight:number
  public name:string = '发面葱油饼'
  constructor(private dataService:DataService,public route:ActivatedRoute) { 
    route.params.subscribe(dishId=>{
      this.id = dishId.id
    })
  }
  
  ngOnInit(): void {
    let that = this
    this.contentHeight = this.windowHeight - 40
    this.dishImgSrc = this.dataService.getImageSrc(this.id)
    this.dataService.getDish(this.id, dish => that.dish=dish)
  }
  back(){
    history.go(-1)
  }
}